package com.itheima.test8;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.util.Scanner;

/**
 * @Author:gy
 * @Date: 2025/09/03 17:21
 * @Description:
 */
public class ClientDemo {
    public static void main(String[] args) throws Exception {
        //键盘录入
        Scanner sc = new Scanner(System.in);
        //创建一个码头
        DatagramSocket ds = new DatagramSocket();
        while (true) {
            String s = sc.nextLine();
            if("886".equals(s)){
                break;
            }
            //如果不是886就发送数据  将发送的消息进行打包
            byte[] bytes = s.getBytes();
            InetAddress ip = InetAddress.getByName("127.0.0.1");
            int port = 10001;
            DatagramPacket dp = new DatagramPacket(bytes,bytes.length,ip,port);
            ds.send(dp);
        }
        ds.close();
    }
}
